<?
$VUE["includes"][]="includes/tiny_mce/jquery.tinymce.js";

if(isset($_REQUEST["action"])){
	if($_REQUEST["action"]=="enregistrer_configuration"){
		
		foreach($_REQUEST as $param=>$valeur){
			if(substr($param,0,4)=="cfg_"){
				$sql->query("update ".CFG_MYSQL_PREFIX."module_config set valeur='".$valeur."' where module='barres_laterales' and nom='".substr($param,4)."'");
			}
		}
		
	}
	if($_REQUEST["action"]=="ajouter_contenu"){
		$var=array();
		$var["nom"]=$_REQUEST["nom"];
		$var["type"]=$_REQUEST["type"];
		if($var["type"]==1) $var["module"]=$_REQUEST["module"];
		else $var["module"]="";
		$var["texte"]="";
		if($var["type"]==2) $var["texte"]=stripslashes($_REQUEST["texte"]);
		if($var["type"]==3) $var["texte"]=stripslashes($_REQUEST["codePHP"]);
		$contenu= new barres_laterales_contenu($var);
		$contenu->ajouter();
	}
	if($_REQUEST["action"]=="editer_contenu"){
		$var=$sql->request_single("select * from ".CFG_MYSQL_PREFIX."barres_laterales_contenu where id=".$_REQUEST["id"]);
		$contenu= new barres_laterales_contenu($var);
		$contenu->nom=$_REQUEST["nom"];
		$contenu->type=$_REQUEST["type"];
		if($contenu->type==1) $contenu->module=$_REQUEST["module"];
		else $contenu->module="";
		$contenu->texte="";
		if($contenu->type==2) $contenu->texte=stripslashes($_REQUEST["texte"]);
		if($contenu->type==3) $contenu->texte=stripslashes($_REQUEST["codePHP"]);
		$contenu->maj();
		
		//echo $contenu->texte;
	}
	if($_REQUEST["action"]=="supprimer_contenu"){
		$var=$sql->request_single("select * from ".CFG_MYSQL_PREFIX."barres_laterales_contenu where id=".$_REQUEST["id"]);
		$contenu= new barres_laterales_contenu($var);
		$contenu->supprimer();
	}
}

$cfg_params=array();
$res=$sql->request("select * from ".CFG_MYSQL_PREFIX."module_config where module='barres_laterales'");
foreach($res as $var){
	$cfg_params[$var->nom]=$var->valeur;
}
$cfg_params["barre_gauche_contenu"]=explode(",",$cfg_params["barre_gauche_contenu"]);
$cfg_params["barre_droite_contenu"]=explode(",",$cfg_params["barre_droite_contenu"]);


